// Waits for message 10, and then hunts pc
// Memory Cells:
//   Cell 0 - If 0, default behavior. If 1, can haste itself.

begincreaturescript;

variables;

short i,target;

body;

beginstate INIT_STATE;
	set_strategy(ME,10);
	if (get_memory_cell(0) > 0)
		bless_char(ME,2);
		else bless_char(ME,0);
	break;


beginstate DEAD_STATE;

break;

beginstate START_STATE; 
	if (my_current_message() == 10) {
		set_act_at_dist(ME,1);
		set_foe_target(ME,pc_num());
		set_state(3);
		}

	// if I have a target for some reason, go attack it
	if (target_ok()) {
		if (dist_to_char(get_target()) <= 16)
			set_state(3);
			else set_foe_target(ME,-1);
		}
	
	if (get_foe_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
	if (who_shot_me() >= 0) {
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}
	if (my_dist_from_start() >= 6) {
		if (get_ran(1,1,100) < 40) 
			return_to_start(ME,1);
		}

	if (am_i_doing_action() == FALSE)
		end_combat_turn();
break;

beginstate 3; // attacking
	if ((get_char_status(ME,1) <= 0) && (get_ran(1,0,100) < 50) && (get_memory_cell(0) > 0)) {
		print_named_str(ME,"speeds up!");
		pc_heard_sound_delay(101,250);						
		run_sparkles_on_char(ME,5,8,1);
		set_char_status(ME,1,3);
		}

	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;

beginstate TALKING_STATE;
	print_str("Talking: It doesn't respond.");
break;